<template>
    <div>
        <el-dialog title="修改分类" width="700px" class="icon-dialog" :visible.sync="show" @open="open"
            :before-close="closeForm" append-to-body>
          <button v-hasPermi="['item:out:edit']">123</button>
        </el-dialog>
    </div>
</template>
<script>
export default {
    name: 'bannerupdate',
    props: {
        show: {
            type: Boolean,
            default: false
        },
        size: {
            type: String,
            default: 'small'
        },
        info: {
            type: Object,
        },
    },
    data() {
        return {
            uptext: 'QProblemClassify',
            cities: [],
            subject: [
                { key: '科目一', value: 0 },
                { key: '科目四', value: 3 },
            ],
            type: [
                { key: '小车', value: 0 },
                { key: '货车', value: 1 },
                { key: '客车', value: 2 },
                { key: '摩托车', value: 3 },
            ],
            is_place: [
                { key: '分类练习', value: 0 },
                { key: '精选练习', value: 1 },
                { key: '地方专题', value: 2 },
                { key: '扣12分', value: 3 },
                { key: '免费试用', value: 4 },
            ],
            form: {
                type: 0,
                is_place: 0,
                subject: 0,
                classify: '',
                image:'',
                sort:'',
                remark:''
            },
            loading: false,
            rules: {
            },
            files: '',
        }
    },
    watch:{
		show(val){
			if(val){
                console.log('1111111');
                this.form = {
                    type: 0,
                    is_place: 0,
                    subject: 0,
                    classify: '',
                    image:'',
                    sort:'',
                    remark:''
                }
			}
		}
	},
    methods: {
        imgUrlfun2(e) {
            if (e) {
                this.form.image = e.path
            } else {
                this.form.image = ''
            }
        },
        open() {
            this.form = this.info
            this.form.pcid = this.info.pcid
        },
        submit() {
            this.$refs['form'].validate(valid => {
                if (valid) {
                    this.loading = true
                    this.form.echo = 'set'
                    getclassifyedit(this.form).then(res => {
                        if (res.code == 200) {
                            this.$message({ message: '操作成功', type: 'success' })
                            this.$emit('refesh_list')
                            this.closeForm()
                        } else {
                            this.$message({ message: '操作失败', type: 'error' })
                        }
                    }).catch(() => {
                        this.loading = false
                    })
                }
            })
        },
        closeForm() {
            this.$emit('update:show', false)
            this.loading = false
            if (this.$refs['form'] !== undefined) {
                this.$refs['form'].resetFields()
            }
        },
    }
}
</script>
<style scoped >
.flexs {
    display: flex;
    width: 500px;
    justify-content: space-between;
    margin-top: 20px;
}

</style>
